package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.LendItem;
import com.atguigu.srb.core.service.LendItemService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 标的出借记录表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/admin/core/lendItem")
@Api(tags = "投资管理")
public class AdminLendItemController {
    @Resource
    LendItemService lendItemService;
    //admin的投资列表的详情里面 /admin/core/lend
    @ApiOperation("投资记录的查询和展示")
    @GetMapping("/investRecord/{lendId}")
    public R getInvestRecord(@PathVariable("lendId")Long lendId){
        //按照时间降序排序,查询的状态是已支付1和已还款的2
        List<LendItem> list = lendItemService.list(Wrappers.lambdaQuery(LendItem.class).eq(LendItem::getLendId, lendId)
                .in(LendItem::getStatus,1,2).orderByDesc());
        return R.ok().data("items",list);
    }

}

